unit fSelToken;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, DBClient,
  dxDBTLCl, dxGrClms, uCommonclass, uCommonVar, uCommonFunc, uVar;

type
  TfrmSelToken = class(TForm)
    ds1: TDataSource;
    cds1: TClientDataSet;
    dxdbgrd1: TdxDBGrid;
    dxdbgrdclmnTokenNum: TdxDBGridColumn;
    dxdbgrdmgclmnModules: TdxDBGridImageColumn;
    dxdbgrdmgclmnOperateType: TdxDBGridImageColumn;
    dxdbgrdclmnAvailableDate: TdxDBGridColumn;
    dxdbgrdmgclmnAuthorizedUser: TdxDBGridImageColumn;
    dxdbgrdclmnReason: TdxDBGridColumn;
    procedure FormShow(Sender: TObject);
    procedure dxdbgrd1DblClick(Sender: TObject);
  private
    { Private declarations }
    gDBInquireSuperMan: TDBInquireSuperMan;
  public
    { Public declarations }
    gModuleID: string;
  end;

var
  frmSelToken: TfrmSelToken;

implementation

{$R *.dfm}

procedure TfrmSelToken.FormShow(Sender: TObject);
begin
  updateTokenExpiredFlag();

  GC_SetImageColumnList(dxdbgrdmgclmnModules, flg_TokenModule);
  GC_SetImageColumnList(dxdbgrdmgclmnOperateType, flg_TokenOperateType);
  GC_SetImageColumnList(dxdbgrdmgclmnAuthorizedUser, getAvailableUserList);

  gDBInquireSuperMan := TDBInquireSuperMan.Create;
  gDBInquireSuperMan.Table := 'HD_TokenManage';
  gDBInquireSuperMan.FieldsPanel := nil;
  gDBInquireSuperMan.DBGrid := dxdbgrd1;
  gDBInquireSuperMan.WhereCondition := ' where used = ''0'' and Modules = '
                                     + QuotedStr(gModuleID)
                                     + ' and Authorized_User = ' + QuotedStr(gUser)
                                     + ' and Available_Date >= '
                                     + QuotedStr(gsWorkDate);
  gDBInquireSuperMan.PrepareData;
  gDBInquireSuperMan.ExecuteOperate;
end;

procedure TfrmSelToken.dxdbgrd1DblClick(Sender: TObject);
begin
  ModalResult := mrOk;
end;

end.
